/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

extern "C" {
 	#include <lua.h>
 	#include <lualib.h>
 	#include <lauxlib.h>
}

#include "../kernel.h"

extern Kernel* g_kernel;

/**
====================
Allow access to console functions through 
LUA
====================
*/
class LUA_Console
{
public:
    static int Exec(lua_State *L) {
        std::string s = luaL_checkstring( L, 1 );
        g_kernel->GetConsole()->Exec( s );
        return 0;
    };

    static const luaL_reg methods[];
};

// - Bind to lua
int luaopen_LUA_Console(lua_State *L) {
    luaL_openlib(L, "console", LUA_Console::methods, 0);
 	return 0;
}
 	
#define method(name) {#name, LUA_Console::name}

const luaL_reg LUA_Console::methods[] = {
        method(Exec),
        {NULL, NULL}
};

